package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {


    /*
     *
     * 插入一条用户订单数据
     *
     * */
    void insert(Orders orders);


    /**
     * 根据订单号查询订单
     *
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    /**
     * 修改订单信息
     *
     * @param orders
     */
    void update(Orders orders);


    /*
     *
     * 历史订单（分页）查询
     *
     * */
    Page<Orders> queryHistoryOrders(OrdersPageQueryDTO ordersPageQueryDTO);


    /*
     *
     * 根据id查询订单
     *
     * */
    @Select("select * from orders where id = #{id}")
    Orders getById(Long id);

    /*
     *
     * 根据订单状态查询订单
     *
     * */
    List<Orders> selectByStatus(Integer Status);


    /*
     *
     * 查询待付款状态的超时订单
     *
     * */
    @Select("select * from orders where status = #{status} and order_time < #{time}")
    List<Orders> selectByStatusAndOrderTime(Integer status, LocalDateTime time);



    /*
    *
    * 获取营业额
    *
    * */
    Double sumByMap(Map map);


    /*
    *
    * //获取每日订单数和有效订单数
    *
    * */
    Integer getOrderCount(Map map);



    /*
     *
     * 查询销量排名top10
     *
     * */
    List<GoodsSalesDTO> getOrderTop10(LocalDateTime beginTime, LocalDateTime endTime);
}
